var userInfo=JSON.parse(sessionStorage.getItem("userInfo"));
if(!userInfo){
    location.href="/loginIndex"
}
Vue.component('selfmediaFlow',{
    props:["list","number","index"],
    template: '<div class="selfMedia-tabCent">\n' +
    '            <div class="selfMedia-list" v-for="item in list" @click.stop="getNext(number,item)">' +
    '                <div class="selfMedia-listImg">' +
    '<div class="zoomImage" v-if="getZoom(item)==1"><img :data-original="item.coverImgSrc" class="lazy"></div>' +
    '<div class="zoomImage1" v-else-if="getZoom(item)==2"><img :data-original="item.coverImgSrc" class="lazy"></div>' +
    '<div v-else><img :data-original="item.coverImgSrc" class="lazy"></div>' +
        // '                <img :data-original="item.coverImgSrc" class="lazy">\n' +
        '                <template v-if="item.advType==1||number==3">\n' +
        // '                    <p class="heatSlide">{{item.categoryName}}</p>\n' +
        '                    <div class="heatSlide-info" :class="{heatSlideInfo:item.totalMoney>0}">\n' +
        // '                        <h6>{{item.title}}</h6>\n' +
        '                        <p class="clearfix">\n' +
        '                            <span class="selfMedia-hetz">{{item.praiseCount}}</span>\n' +
    //     // '                            <span class="selfMedia-map">{{item.cityName}}</span>\n' +
    // '                                <span class="selfMedia-money1" v-if="index"></span>\n' +
    //     '                            <span class="selfMedia-money" v-else>赚<span>{{item.rewardCount}}</span></span>\n' +
        '                        </p>\n' +
        '                    </div>' +
        '                </template>' +
    '                    <div class="circle-imgShadow"></div>\n' +
    '                    <div class="circle-btnclose" v-if="index==3" @click.stop="getDeleteVideo(item.id)"></div>\n' +
        '                <template v-if="item.advType==2">\n' +
    '                        <div class="advType-info">广告<span class="selfMedia-money1"></span></div>\n' +
        // '                    <div class="advType-info" v-else>广告<span class="advType-infoData">{{item.vedioLength}}<span></span>抢红包</span></div>\n' +
        '                </template>\n' +
    '                </div>\n' +
'                    <div class="heatSlide-headInfo">' +
    // '<span class="selfMedia-morecz"></span>' +
'                       <h6>{{item.title}}</h6>' +
    '                   <div class="clearfix"><span :style="bgimg(item.headImg)" @click.stop="getUser(item.uid)"></span><strong class="selfMedia-uName">{{item.uName||item.name}}</strong><strong class="selfMedia-map">{{item.cityName}}</strong>' +
    '                   </div>' +
'                    </div>\n' +
    '            </div>\n' +
    '        </div>',
    data: function () {
        return {}
    },
    methods:{
        bgimg:function(url){
            url = url?url:"";
            return {
                "background-image":'url("'+url+'"),url("")'
            }
        },
        getZoom:function(item){
            if(item.coverImgHeight>(item.coverImgWidth*1.33)){
                //console.log(Math.round(item.coverImgWidth*1.33))
                // return "50%";
                return 1;
            }else if(item.coverImgHeight<(item.coverImgWidth*0.66)){
                return 2;
            }
        },
        getDeleteVideo:function(videoId){
            this.$emit("deletevideo",videoId);
        },
        //跳转页面
        getNext:function(type,item,index){
            console.log(type)
            console.log(item)
            if(type==1||type==3){
                if(item.advType==1){  //数据
                    location.href="/see/selfMediaVd?id="+item.id+"&uid="+userInfo.id+"&sourceType=1";
                }else if(item.advType==2){   //广告
                    location.href="/see/adDetails?id="+item.id+"&uid="+item.uid;
                }
            }else if(type==2) {
                if(item.advType==1){  //数据
                    if(item.isweb==1){
                        location.href ="/cityAd/travelsInfo?cityAdvId="+item.cityAdvId;
                    }else if(item.isweb==0){
                        location.href="/cityAd/cityAdVideo?cityAdvId="+item.cityAdvId;
                    }
                }else if(item.advType==2){   //广告
                    location.href="/see/adDetails?id="+item.id+"&uid="+item.uid;
                }
            }else if(type==4){
                location.href ="/cityAd/travelsInfo?cityAdvId="+item.id;
            }else if(type==5){
                if(item.type==1){   // 1自媒体 2企业广告3城市广告4传统文化
                    location.href="/see/selfMediaVd?id="+item.id+"&uid="+userInfo.id+"&sourceType=1";
                }else if(item.type==2){
                    location.href="/see/adDetails?id="+item.id+"&uid="+item.uid;
                }else if(item.type==3){
                    location.href="/cityAd/cityAdVideo?cityAdvId="+item.id;
                }else if(item.type==4){

                }
            }else if(type==6){
                location.href ="/cityAd/travelsInfo?cityAdvId="+item.id;
            }else if(type==7){
                location.href="/see/selfMediaVd?id="+item.id+"&uid="+userInfo.id+"&sourceType=1";
            }else{
                return false;
            }
        },
      /*  //跳转页面
        getNext:function(id,uid){
            location.href="/see/selfMediaVd?id="+id+"&uid="+userInfo.id+"&sourceType=1";
        },*/
        //个人中心
        getUser:function(item){
            console.log(item);
            location.href="/userHomepage?id="+item;
        }
    }
});